<?php
	$item = $this;
	$user = $item->getUser();
?>
<li>
	<div class="Widget_Flow_GenericFlow_Item" item_id="<?php echo $item->getGenericId(); ?>">
		<div class="Content">
			<?php if($item->isDeletable()) : ?><a class="Delete Icon"></a><?php endif ?>
			<div class="Left Part">
				<img src="<?php echo _s($user->getThumbPath()); ?>" alt="<?php echo _s($user->getFullName()); ?>" />
			</div>
			<div class="Right Part">
				<h5><a href="<?php echo _s($user->getUrl()); ?>"><?php echo _s($user->getFullName()); ?></a>
				<?php
					if( method_exists($item->getFlow(), 'getUser' ) && !$item->getFlow()->getUser()->is( $item->getUser() ) ) :
						$dest = $item->getFlow()->getUser();
						?> &rArr; <a href="<?php echo _s($dest->getUrl()); ?>"><?php echo _s($dest->getFullName()); ?></a><?php
					endif
				?></h5>
				<p><?php echo nl2br(_s($item->getMessage())); ?></p>
				<h6><?php echo \Library\I18n\En\Date::toHumanRelative( $item->getPublicationTime() ); ?><?php if( $item->isCommentable( _u() ) ) : ?>
				&nbsp;&nbsp;-&nbsp;&nbsp;<a action="comment">Comment</a>
				<?php endif ?>
				<?php if( $item->isLikable( _u() ) ) : ?>
				&nbsp;&nbsp;-&nbsp;&nbsp;<a action="like" currentIndex="<?php echo $item->isLikedBy( _u() ) ? 1 : 0 ?>"></a>
				<?php endif ?></h6>
				
				<?php foreach( $this->getLinks() as $link ) : ?>
				<?php echo $link->view(); ?>
				<?php endforeach ?>
			</div>
			<div style="clear: both"></div>
		</div>
		
		<ul>
			<?php $likes = $item->getLikes(); ?>
			<li class="Like<?php if( $likes ) : ?> Visible<?php endif?>">
				<div class="Content">
				<p><?php echo $likes; ?></p>
				</div>
			</li>
			<?php
				$comments = $this->getComments(); 
				if( count($this->getComments()) > 3 ) :
			?>
			<li class="View">
				<div class="Content">
				<p><a action="view">View all 5 posts</a></p>
				</div>
			</li>
			<?php
				$comments = array_slice( $comments, -2, 2 );
				endif
			?>
			<?php foreach( $comments as $comment ) : ?>
			<?php echo $comment->view(); ?>
			<?php endforeach ?>
			<?php if( $item->isCommentable( _u() ) ) : ?>
			<li class="Writer <?php if( $comments ) : ?>Visible<?php endif ?>">
				<div class="Content">
					<div class="Left Part">
					<img src="<?php echo _s(_u()->getMiniPath()); ?>" alt="<?php echo _s(_u()->getFullName()); ?>" />
					</div>
					<div class="Right Part">
						<textarea name="comment[message]"></textarea>
						<a class="Button">Share</a>
					</div>
					<div style="clear:both"></div>
				</div>
			</li>
			<?php endif ?>
		</ul>
	</div>
</li>
